home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / datedem.com / DATEDEMO.C next >
Encoding:
C/C++ Source or Header  |  1989-03-11  |  1.9 KB  |  51 lines

  1. /* datedemo.c is just a short demo program which uses most of the
  2.    functions contained in the dates.c library.  By using the listing
  3.    of this program you should be able to incorporate the dates routines
  4.    in your programs.
  5.    To compile datedemo.c with the dates library type the following
  6.    from the comand line:
  7.    tcc -ms datedemo.c dates.obj
  8.    Have fun and enjoy!  Gerry Rohr
  9. */
  10. #include "dates.h"
  11. #include <stdio.h>
  12.  
  13. void main(void)
  14. {
  15.    DATE in_date;
  16.    JULDATE j_date;
  17.    int i;
  18.  
  19.    in_date = 19890310;
  20.    printf("-----Start of Test Run-----\n");
  21.    printf("%ld is !%s!\n",in_date,dtoa(in_date));
  22.    printf("Month of %ld is %d\n",in_date,month(in_date));
  23.    printf("Day of %ld is %d\n",in_date,day(in_date));
  24.    printf("Year of %ld is %d\n",in_date,year(in_date,1));
  25.    printf("Year of %ld is %d\n",in_date,year(in_date,0));
  26.    greg_to_jul(in_date,&j_date);
  27.    printf("Julian date is %d/%d or %s\n",j_date.yr,j_date.day,jul_dt_st(&j_date));
  28.    in_date = jul_to_greg(&j_date);
  29.    printf("Converted to greg is %ld\n",in_date);
  30.    printf("Converted back is !%s!\n",dtoa(in_date));
  31.    next_day(&in_date);
  32.    printf("Next day is !%s!\n",dtoa(in_date));
  33.    printf("Full date string is %s\n",full_date_st(in_date));
  34.    prev_day(&in_date);
  35.    printf("Prev day is !%s!\n",dtoa(in_date));
  36.    printf("Month of %ld is %s\n",in_date,month_name(month(in_date)));
  37.    for(i=0;i<6;i++)
  38.    {
  39.       printf("Day of %ld is %s\n",in_date,day_name(in_date));
  40.       next_day(&in_date);
  41.    }
  42.    printf("Valid_date returned %d\n",valid_date(in_date));
  43.    in_date = NO_DATE;
  44.    printf("NO_DATE is !%s!\n",dtoa(in_date));
  45.    in_date = 19890155L;
  46.    printf("Valid_date of %ld is %d\n",in_date,valid_date(in_date));
  47.    in_date = 18981315L;
  48.    printf("Valid_date of %ld is %d\n",in_date,valid_date(in_date));
  49.    printf("-----End of Test Run-----");
  50. } /* end of main */
  51.